﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Web;
using System.Data;
using System.IO;

namespace Moddb08_WCF
{
    // NOTE: If you change the interface name "Itest" here, you must also update the reference to "Itest" in Web.config.
    //Use xml format.
    [XmlSerializerFormat]

    [ServiceContract]
    public interface Itest
    {
        [OperationContract]
        [WebGet(UriTemplate = "tables/")]
        Tables GetAllTables();

        [OperationContract]
        [WebGet(UriTemplate = "tables/{tableName}/columns/")]
        Columns GetAllColumnsOfTable(string tableName);

        [OperationContract]
        [WebGet(UriTemplate = "tables/{tableName}/rows")]
        Rows GetAllRows(string tableName);

        [OperationContract]
        [WebGet(UriTemplate = "tables/{tableName}/rows/{id}/{column}")]
        Stream GetColumnData(string tableName, string id, string column);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "tables/")]
        void AddNewTable(Table table);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "tables/{tableName}/columns/")]
        void AddNewColumn(Column input, string tableName);

        [OperationContract]
        [WebInvoke(Method = "DELETE", UriTemplate = "tables/{tableName}/columns/{columnName}")]
        void DeleteColumn(string tableName, string columnName);

        [OperationContract]
        [WebInvoke(Method = "PUT", UriTemplate = "tables/{tableName}/rows/{rowID}/{columnName}")]
        void InsertDataToColumn(Stream data, string tableName, string rowID, string columnName);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "tables/{tableName}/rows/")]
        void AddNewRow(string tableName);

        [OperationContract]
        [WebInvoke(Method = "DELETE",UriTemplate="tables/{tableName}/rows/{id}")]
        void DeleteRowInTable(string tableName, string id);

        [OperationContract]
        [WebInvoke(Method = "DELETE", UriTemplate = "tables/{tableName}" )]
        void DeleteTable(string tableName);
    }
}
